from playwright.sync_api import sync_playwright

def run(playwright):
    browser = playwright.chromium.launch(headless=False)
    context = browser.new_context()

    # Open new page
    page = context.new_page()

    # Go to http://localhost:3000/user/login
    page.goto("http://localhost:3000/user/login")

    # Click [placeholder="请输入帐户名 / admin"]
    page.click("[placeholder=\"请输入帐户名 / admin\"]")

    # Fill [placeholder="请输入帐户名 / admin"]
    page.fill("[placeholder=\"请输入帐户名 / admin\"]", "admin")

    # Press Tab
    page.press("[placeholder=\"请输入帐户名 / admin\"]", "Tab")

    # Fill [placeholder="密码 / 123456"]
    page.fill("[placeholder=\"密码 / 123456\"]", "123456")

    # Press Tab
    page.press("[placeholder=\"密码 / 123456\"]", "Tab")

    # Fill [placeholder="请输入验证码"]
    page.fill("[placeholder=\"请输入验证码\"]", "6666")

    # Click button:has-text("确 定")
    page.click("button:has-text(\"确 定\")")

    

    # ---------------------
    context.close()
    browser.close()

with sync_playwright() as playwright:
    run(playwright)